<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/sale/include/common-base.jsp"%>
  <title>理财产品登记管理-${titleName}</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- Part 一、 以下是body主体内容的模块区域 -->
<body class="hold-transition skin-yellow sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/sale/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/sale/left.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
          <div class="box box-info">
             <!--搜索title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-search"></i> 理财产品审核搜索</h3>
              </div>
            <!--搜索title  end --> 
            <div class="box-body">
			  <form id="searchForm" class="form-horizontal">
				<input type="hidden" name="pageName" value="financial-reg-list">
				<input type="hidden" name="formName" value="searchForm">
				<input type="hidden" name="trpProduct.w_sysName" value="${sysName }">
				<input type="hidden" name="trpProduct.w_proStatus" value="1">
				
				<div class="form-group">
					<div class="form-group col-sm-2 text_r"><label class="control-label" >产品名称：</label></div>
					<div class="form-group col-sm-3">
						<input type="text" class="form-control clean"  name="trpProduct.wl_proName" value=""/>
					</div>
					<div class="form-group col-sm-2 text_r"><label class="control-label" >产品代码：</label></div>
					<div class="form-group col-sm-3">
						<input type="text" class="form-control clean"  name="trpProduct.wl_proNo" value=""/>
					</div>
				</div>
				
				<center>
				   <div class="form-group col-sm-12 box-footer clearfix">
				       <button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-edit-circle"></i> 查询</button> 
				       <button type="button" class="btn btn-warning" onclick="mytools.cleanData('#searchForm');">重置 </button>
				   </div>
				</center>
				
			  </form>
            </div>
	     </div>
	     <!------- 搜索 end -------->
           
        <!------- 列表 start -------->
          <div class="box box-success">
            <!--列表title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-user"></i> 理财产品审核列表 
                 </h3>
              </div>
            <!--列表title  end --> 
              <div class="box-body">
                <table id="dataList" class="table table-bordered table-hover" >
                <thead class="bg-success">
                <tr>
						<th name="trpProduct.proName">产品名称</th>
						<th name="trpProduct.proNo">产品代码</th>
						<th name="trpProduct.cateName">品种类型</th>
						<th name="trpProduct.proCanal">渠道</th>
						<th name="trpProduct.proRemark">产品描述</th>
                  		<th>操作</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
           </div>
        <!------- 列表 end -------->
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/sale/foot.jsp" %>
  <!-- foot start -->
  

 

<div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">查看详情</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="myTab-view">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					               <div class="tab-pane active" id="tabView_1">
					                  <form class="form-horizontal" role="form" id="viewForm1" action="javascript:void(0)">
							             <input type="hidden" name="pageName" value="financial-reg-list"/>
										<input type="hidden" name="formName" value="editForm"/>
										<input type="hidden" name="trpProduct.w_proId" data-name="trpProduct.proId" />
										<input type="hidden" id="trpProductId" name="trpProduct.proStatus" value="5"/>
							            
							            
							            <!--trpProduct start-->
						                	
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">产品名称</label>
												<div class="col-sm-8">
													<span data-name="trpProduct.proName"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">产品代码</label>
												<div class="col-sm-8">
													<span data-name="trpProduct.proNo"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">产品描述</label>
												<div class="col-sm-8">
													<span data-name="trpProduct.proRemark"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">品种类型</label>
												<div class="col-sm-8">
						                			<span data-name="trpProduct.cateName" data-dict-url="doCode=dymicSql&modelTypes=s_trpCate"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">额度管理级别</label>
												<div class="col-sm-8">
						                			<span data-name="trpProduct.proLevel" data-dict-url="doCode=dictItemList&cateEname=lcLevel"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">理财凭证</label>
												<div class="col-sm-8">
						                			<span data-name="trpProduct.proVoucher" data-dict-url="doCode=dictItemList&cateEname=lcVoucher"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">理财方式</label>
												<div class="col-sm-8">
						                			<span data-name="trpProduct.proMode" data-dict-url="doCode=dictItemList&cateEname=lcMode"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">渠道</label>
												<div class="col-sm-8">
													<span data-name="trpProduct.proCanal"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">用户名称</label>
												<div class="col-sm-8">
						                			<span data-name="trpProduct.userId" data-dict-url="doCode=dymicSql&modelTypes=s_member"></span>
												</div>
											</div>
											
								       <!--trpProduct end-->
								       
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
												<button class="btn btn-danger" type="button" onclick="submitForm1('viewForm1','0');"> 不通过 </button>
												<button class="btn btn-success" type="button" onclick="submitForm1('viewForm1');"> 通过 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>
					</div>
				</div>
				<!-- /.modal-content -->
	</div>		
</div>
</body>

<!-- Part 二、以下是template模板定义的模块区域 -->
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
					<td><?=strUtil.doNull(rows[i].proName,'')?></td>
					<td><?=strUtil.doNull(rows[i].proNo,'')?></td>
					<td><?=strUtil.doNull(rows[i].cateName,'')?></td>
					<td><?=strUtil.doNull(rows[i].proCanal,'')?></td>
					<td><?=strUtil.doNull(rows[i].proRemark,'')?></td>
              <td>
						<button type="button" class="btn btn-success btn-xs" onclick="toLoad('<?=rows[i].proId?>','view');">审核</button>  
										
				</td>
		</tr>
   <?}?>  		
</script>

</html>

<!-- Part 三、 以下是js模块区域 -->
<script>
var clickMenu = "financial-reg-audit";
var myPage,dataListId,searchFormId,mainObj,mainId;
myPage = 10;//定义列表数据
dataListId = "dataList";//显示列表数据div的id
searchFormId = "searchForm";//搜索表单Id
mainObj = "trpProduct";//主对象
mainId = "proId";//主对象主键

$(function () {
	//1、加载分页列表数据
	getTableData();
	
	//2、控制是否启用token
	//setToken();
	
	//可在下面补充其他初始化方法（如数据字典、页面加载数据等）
	
 });
 
 $(function () {
	//设置数据行选中效果
	$('#'+dataListId+' tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	        }
	        else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     //var id = $('tr.selected th').eq(0).html();
	} );
 });
//日历框添加样式
var dateObject = $('.datepicker').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true
});
//打开添加页面

//数据toLoad读取（查询、编辑）数据
function toLoad(id,type){
	var proStatus=1;
	var formName = $("#searchForm").find("input[name='formName']").val();
	var paramLoadData = {"pageName":"financial-reg-list","formName":formName,"trpProduct.w_proId":id};
	showModal(type);//控制弹出view/edit窗口
	$.ajax({
	    type:'get',
	   	url:common_info_url,
	    data: paramLoadData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	console.log(myData);
	    	//反显加载数据
			FormUtil.loadView("trpProduct", myData);
			if("edit"==type){		
				DictUtil.getCommonDictData("select","#editForm1_trpProduct_cateId","trpProduct.cateId","doCode=dymicSql&modelTypes=s_trpCate","{value:'cateId',text:'cateName',other:'cateNo,cateType'}",myData.cateId);
				DictUtil.getCommonDictData("select","#editForm1_trpProduct_proLevel","trpProduct.proLevel","doCode=dictItemList&cateEname=lcLevel","",myData.proLevel);
				DictUtil.getCommonDictData("select","#editForm1_trpProduct_proVoucher","trpProduct.proVoucher","doCode=dictItemList&cateEname=lcVoucher","",myData.proVoucher);
				DictUtil.getCommonDictData("select","#editForm1_trpProduct_proMode","trpProduct.proMode","doCode=dictItemList&cateEname=lcMode","",myData.proMode);
				DictUtil.getCommonDictData("select","#editForm1_trpProduct_userId","trpProduct.userId","doCode=dymicSql&modelTypes=s_member","{value:'memberId',text:'memberCname',other:'memberEname'}",myData.userId);
			}
	  	}
	});
}
//删除调用

//弹出框
function showModal(type){
	if("view"==type){
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		mytools.cleanData(".editFormBody");//清空表单元素上次填写的内容；
		setValidate(".editFormBody");//定义edit表单验证属性
		mytools.cleanValidate(".editFormBody");//清空上次校验规则提示
		$("#my_modal_edit").modal("show");
	}
}
//加载列表数据
function getTableData(){
	deleteAllRow(dataListId);
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
		   dataType:'json',
		   success: function(myData){
		   console.log(myData);
			var data = baidu.template(dataListId+"-template",eval(myData));  
			$("#"+dataListId+"-body").html(data);
			  var option= {
					   ele:$("#"+dataListId+"-page")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:common_list_url+"?"+$("#"+searchFormId).serialize()
				   }
				generatePages(option);
		   }
		});	
  }


//提交tab1表单数据
function submitForm1(formId,type){
	//校验规则-表单提交时触发
// 	var validate = $('#'+formId).data('bootstrapValidator').validate();
// 	var validate = $('#'+formId).data('bootstrapValidator').validate();
// 	if(!validate.isValid()){ //如果校验不通过就返回
// 	    return;  
// 	}
	if('0'==type){
	$("#trpProductId").val(4);
	var index_submit = layer.confirm('您确定要拒绝审核信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		var result = submitForm(formId);
		if(result){
      		layer.alert('操作成功！', {closeBtn: 0 });
      		mytools.closeModal("my_modal_view");
      		refresh();
		
	  	}
	});
	}else{
	$("#trpProductId").val(5);
	var index_submit = layer.confirm('您确定要审核信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		var result = submitForm(formId);
		if(result){
      		layer.alert('操作成功！', {closeBtn: 0 });
      		mytools.closeModal("my_modal_view");
      		refresh();
		
	  	}
	});
	}
	
 }
//提交表单数据
function submitForm(formId){
	var result;
	var index_load = layer.load(1, {shade: false});
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    async:false,
	    dataType:'json',
	    success: function(myData){ 
	     console.log(myData);
	        if(myData.flag=="T"){
	        	result = myData;
	    	}else{
	    		setToken();
	     		layer.alert(myData.msg);
	    	}
	        layer.close(index_load);
	  	},
	     error: function (e) {
		     layer.close(index_load);
     	} 
	});	
	return result;
}

//刷新
function refresh(){
	getTableData();
}
//设置token
function setToken(){
	$.ajax({
	    type:'get',
	    url:'${ctx}/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	console.log(myData);
			$('.formToken').val(myData);
	  	}
	});	
}


/**** Part 四、以下是自定义新增方法  ****/
//1.定义校验规则-定义
function setValidate(id){
	$(id).bootstrapValidator({
	    feedbackIcons: {
	        valid: 'glyphicon glyphicon-ok',
	        invalid: 'glyphicon glyphicon-remove',
	        validating: 'glyphicon glyphicon-refresh'
	    },/** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
	    fields: {
	        "trpProduct.proName": {
	            validators: {
	                notEmpty: {
	                    message: '自定义属性不能为空！'
	                }
	            }
	        }
	    }
	});
}


function changeSelectTo(cateId,cateNoId,cateNameId){
	var cateNoValue=$("#"+cateId).find("option:selected").attr("cate-no");
	var cateNameValue=$("#"+cateId).find("option:selected").text();
	$("#"+cateNoId).val(cateNoValue);
	$("#"+cateNameId).val(cateNameValue);
}

</script>